package com.crealth.mapper;

import java.sql.Timestamp;
import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.crealth.model.CdrModel;


public abstract interface CdrMapper {
	
	public abstract void createCdrTable(
			@Param("tableName")String tableName);
	
    public abstract Long insertCdrObj(
    		@Param("tableName")String tableName, 
    		@Param("userID")int userID,
    		@Param("callee")String callee,
    		@Param("holdTm")int holdTm,
    		@Param("endreason")String endreason,
    		@Param("recordName")String recordName,
    		@Param("dialType")String dialType);
    
    //  查询  录音的  cdr
    public abstract List<CdrModel> selectRecordCdr(
    		@Param("tableName")String tableName,
    		@Param("strSql")String strSql);
    
    //  20秒内 是否有记录  有则查询出ID
    public abstract Long selectUserCdrExit(
    		@Param("tableName")String tableName, 
    		@Param("userID")int userID,
    		@Param("callee")String callee);
    
    public abstract Long selectLastCdrID(
    		@Param("tableName")String tableName);
    
    public abstract void updateCdrCallendByID(
    		@Param("tableName")String tableName,
    		@Param("id")long id,
    		@Param("userID")long userID,
    		@Param("holdTm")int holdTm,
    		@Param("ringingTime")int ringingTime,
    		@Param("endreason")String endreason,
    		@Param("recordName")String recordName);  

    public abstract Integer selectUserOnedayCallSum(
    		@Param("tableName")String tableName,
    		@Param("userID")int userID);    
    
    public abstract Integer selectUserHoldCallSum(
    		@Param("tableName")String tableName,
    		@Param("userID")int userID);
    
    public abstract Integer selectUserRingCallSum(
    		@Param("tableName")String tableName,
    		@Param("userID")int userID);
    
    //  总的通话时长
    public abstract Integer selectUserHoldTimeSum(
    		@Param("tableName")String tableName,
    		@Param("userID")int userID);
    
    //  通话大于一分钟的数量
    public abstract Integer selectGreaterThanOneminute(
    		@Param("tableName")String tableName,
    		@Param("userID")int userID
    		);
    
    
    public abstract List<CdrModel> selectAllCdr(@Param("tableName")String tableName);
    
    public abstract void insertCdrAllField(
    		@Param("tableName")String tableName,
    		@Param("userID")int userID,
    		@Param("callee")String callee,
    		@Param("holdTm")int holdTm,
    		@Param("endreason")String endreason,
    		@Param("callTime")Timestamp callTime);
      
    public abstract List<String> selectAllCdrCalleeByUserID(
    		@Param("tableName")String tableName,
    		@Param("userID")int userID);
    
    public abstract Integer selectCdrByPhoneAndTm(
    		@Param("tableName")String tableName,
    		@Param("phoneNum")String phoneNum,
    		@Param("uploadTm")Timestamp uploadTm);
    
    
    
    public abstract Integer selectTableCount(
    		@Param("tableName")String tableName);
    

    
    
}
